package com.atguigu.yygh.host.controller;

import com.atguigu.yygh.common.R;
import com.atguigu.yygh.host.service.ScheduleService;
import com.atguigu.yygh.model.hosp.Schedule;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author DongYu Zhou
 * @date 2022/6/27 20:00
 */
@Api(description = "排班接口")
@RestController
@RequestMapping("/admin/hosp/schedule")
public class ScheduleController {
    /**
     分析接口
     *参数：page,limit,hoscode,depcode
     *返回结果：map存入：list<BookingScheduleRuleVo>,total
     */
    @Autowired
    private ScheduleService scheduleService;

    /**
     * 根据医院编号 和 科室编号 ，查询排班规则数据
     * @param page 页数
     * @param limit l
     * @param hoscode 医院编码
     * @param depcode 科室
     * @return
     */
    @ApiOperation(value ="查询排班规则统计数据")
    @GetMapping("getScheduleRule/{page}/{limit}/{hoscode}/{depcode}")
    public R getScheduleRule(@PathVariable("page") Long page,
                             @PathVariable("limit") Long limit,
                             @PathVariable("hoscode") String hoscode,
                             @PathVariable("depcode") String depcode){ //depcode在实体类中是Data类型

        Map<String,Object> map =
                scheduleService.getScheduleRule(page,limit,hoscode,depcode);
        return R.ok().data(map);
    }

    /**
     * "查询排班详细信息"
     * @param hoscode
     * @param depcode
     * @param workDate
     * @return
     */
    @ApiOperation(value = "查询排班详细信息")
    @GetMapping("getScheduleDetail/{hoscode}/{depcode}/{workDate}")
    public R getScheduleDetail( @PathVariable String hoscode,
                                @PathVariable String depcode,
                                @PathVariable String workDate) {
        List<Schedule> list =
                scheduleService.getScheduleDetail(hoscode,depcode,workDate);
        return R.ok().data("list",list);
    }

}
